package router

import (
	"blog_demo/api"
	"blog_demo/views"
	"net/http"
)

func Router() {
	// 主页
	http.HandleFunc("/", views.HTML.Index)
	// 分类
	http.HandleFunc("/c/", views.HTML.Category)
	// 登录
	http.HandleFunc("/login", views.HTML.Login)
	http.HandleFunc("/api/v1/login", api.API.Login)
	// 文章
	http.HandleFunc("/p/", views.HTML.Detail)
	http.HandleFunc("/writing", views.HTML.Writing)

	http.HandleFunc("/api/v1/post", api.API.SaveAndUpdatePost)

	// static
	http.Handle("/resource/",
		http.StripPrefix("/resource/",
			http.FileServer(http.Dir("public/resource"))))
}
